from odoo import fields, models


class AgriPest(models.Model):
    _name = 'agri.pest'
    _description = '虫害知识库'
    _inherit = ['mail.thread', 'mail.activity.mixin']

    name = fields.Char(string='虫害名称', required=True, tracking=True)
    latin_name = fields.Char(string='学名')
    common_alias = fields.Char(string='俗称')
    pest_type = fields.Selection(
        selection=[
            ('chewing', '咀嚼式'),
            ('sucking', '刺吸式'),
            ('boring', '蛀食式'),
            ('mites', '螨类'),
            ('other', '其他'),
        ],
        string='取食方式',
        default='chewing',
        tracking=True,
    )
    crop_ids = fields.Many2many('agri.crop', string='常见寄主')
    harmful_stages = fields.Char(string='主要为害时期')
    symptoms = fields.Html(string='危害表现', sanitize=False)
    treatment = fields.Html(string='应急处理', sanitize=False)
    prevention = fields.Html(string='综合防控', sanitize=False)
    active_seasons = fields.Char(string='活跃季节')
    monitoring_tips = fields.Text(string='巡查要点')
    recommended_products = fields.Char(string='推荐药剂/诱捕方式')
    removal_tips = fields.Text(string='人工清除技巧')
    audio_summary = fields.Text(string='语音摘要')
    reference_links = fields.Char(string='参考链接')
    image_1920 = fields.Image(max_width=1920, max_height=1920)
    active = fields.Boolean(default=True)

